package lab03.Test13;

import java.sql.*;

/**
 * Created by 星月 on 2017/11/23.
 */
public class Test {
    public static void main(String[] args) {
        //加载驱动程序
        Connection connection=null;

        Statement statement=null;

        ResultSet resultSet=null;//只有查询时才会使用result

        //表的名字叫t_users
        String sql="insert into t_users(id,username,password) values(2,'zhan','123')";
        try {
            Class.forName("com.mysql.jdbc.Driver");
            connection= DriverManager.getConnection(
                    "jdbc:mysql://localhost:3306/sctu?serverTimezone=UTC",
                    "root",
                    "123456"
            );//alt+enter+第一个
            statement=connection.createStatement();
            statement.execute(sql);

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            try {
                statement.close();
                connection.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
}
